package com.samsung.utils.phone.activities;

import com.samsung.utils.phone.helpers.HelperFunctions;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class CustomNetworkListener extends BroadcastReceiver {

	NetworkStateChangedListener listener;

	public CustomNetworkListener(NetworkStateChangedListener listener) {
		this.listener = listener;
	}

	@Override
	public void onReceive(Context context, Intent intent) {

		/*boolean noConnectivity = intent.getBooleanExtra(
				ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
		String reason = intent.getStringExtra(ConnectivityManager.EXTRA_REASON);
		boolean isFailover = intent.getBooleanExtra(
				ConnectivityManager.EXTRA_IS_FAILOVER, false);

		NetworkInfo currentNetworkInfo = (NetworkInfo) intent
				.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
		NetworkInfo otherNetworkInfo = (NetworkInfo) intent
				.getParcelableExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO);
		 */
		if (listener != null) {
			boolean isOnline = HelperFunctions.isMyServiceRunning(context);
			listener.hasConnection(isOnline);

		}

		// Log.v("asd", "asd" + noConnectivity);
		// do application-specific task(s) based on the current network
		// state, such
		// as enabling queuing of HTTP requests when currentNetworkInfo is
		// connected etc.
	}

}
